import axios from "axios";
import React, { memo } from "react";
import AppLayout from "../components/app-layout";

// 数据脱水
const About = memo((props) => {
  const { name, banner, recommend } = props;
  return (
    <AppLayout>
      <h2>{name}</h2>
      {banner.list.map((item) => {
        return <div key={item.title}>{item.title}</div>;
      })}
    </AppLayout>
  );
});

// 数据的注入
About.getInitialProps = async (props) => {
  const res = await axios({
    url: "http://123.207.32.32:8000/home/multidata",
  });
  return {
    name: "why",
    banner: res.data.data.banner,
    recommend: res.data.data.recommend.list,
  };
};

export default About;
